<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box{
            width: 300px;
            height: 300px;
            border: 5px groove black;
            border-radius: 25px;
            display: none;
            background: cornflowerblue;
        }
        .active{
            display: block;
        }
    </style>
</head>
<body>
    <div class="box active"></div>
    <button>添加</button>
    <button>删除</button>
    <button>切换</button>
    <script>
        var box = document.querySelector('.box')
        // 修改类名
        // box.className = ''

        var btn = document.querySelectorAll('button')
        btn[0].onclick = function(){
        //添加类名
        box.classList.add('active')
        }
        btn[1].onclick = function(){
            //删除类名
            box.classList.remove('active')
        }
        btn[2].onclick = function(){
            //切换类名
            box.classList.toggle('active')
        }
    </script>
</body>
</html>